<?php set_time_limit(300);
error_reporting(E_ERROR);

function curl_get($durl) {
  $t = parse_url($durl);
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL,$durl);
  curl_setopt($ch, CURLOPT_HEADER, false);  
  curl_setopt($ch, CURLOPT_TIMEOUT,5);
  curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
  curl_setopt($ch, CURLOPT_REFERER, "http://$t[host]/");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
 // curl_setopt($ch, CURLOPT_RANGE, 1-100);
  $r = curl_exec($ch);
  curl_close($ch);
  return $r;
}


function curl_get_montior_type ($Machine_sn) {

//$page = curl_get( 'http://support1.lenovo.com.cn/lenovo/wsi/usercenter/computersearch/StandardMyComputerSearch.aspx?id=WS70087123');
$page = curl_get( 'http://support1.lenovo.com.cn/lenovo/wsi/usercenter/computersearch/StandardMyComputerSearch.aspx?id='.$Machine_sn);

$start = strstr($page,"litMachineName_LK");
$start_n = strpos($start,"span");
//echo $start_n."****";

$result = substr($start,40,($start_n-42));

//$result = substr($start,0,($start_n+100));

 //$lines_string=implode('',$arr);
 
 
 $result = str_replace("+"," ",$result);
 return urldecode($result);
//echo $result;
}



//echo curl_get_montior_type($_REQUEST['sn']);
?>


	<?php
	echo '******************';
	echo $_REQUEST['hidden_sn'];
			$filepath="./aa.sqlite3";

			$db=new SQLite3($filepath); //打开此路径数据库文件

			$sql="select '0000000000000'"; //查询记录
	?>
	
	
	
	
	
	
	
	
	<table border=0 cellpadding=0 cellspacing=0>
<tr bgcolor=#f87820>
<td><img src=img/blank.gif width=40 height=25></td>
<td class=tabhead><img src=img/blank.gif width=100 height=6><br><b>  type		</b></td>
<td class=tabhead><img src=img/blank.gif width=40 height=6><br><b>  S_T		</b></td>
<td class=tabhead><img src=img/blank.gif width=100 height=6><br><b>  sn		</b></td>
<td class=tabhead><img src=img/blank.gif width=100 height=6><br><b>  pn   		</b></td>

<td class=tabhead><img src=img/blank.gif width=100 height=6><br><b>  mo     	</b></td>
<td class=tabhead><img src=img/blank.gif width=120 height=6><br><b>  lucky      	</b></td>
<td class=tabhead><img src=img/blank.gif width=80 height=6><br><b>     		</b></td>
<td class=tabhead><img src=img/blank.gif width=80 height=6><br><b>     		</b></td>
<td class=tabhead><img src=img/blank.gif width=80 height=6><br><b>     		</b></td>
<td class=tabhead><img src=img/blank.gif width=50 height=6><br><b>      		</b></td>
<td><img src=img/blank.gif width=10 height=25></td>
</tr>



<?php

$result=$db->query("SELECT * FROM montior;");
	
	$i=0;
	while( $row=$result->fetchArray(SQLITE3_ASSOC) )
	{
		if($i>0)
		{
			echo "<tr valign='bottom'>";
			echo "<td bgcolor='#ffffff'			background='img/strichel.gif' colspan='6'><img src=img/blank.gif width='1' height='1'></td>";
			echo "</tr>";
		}
		echo "<tr valign='center'>";
//		echo "<td class='tabval'><img src=img/blank.gif width=10 height=20></td>";
		echo "<td class='tabval'><b>".htmlspecialchars($row['id'])."</b></td>";
		
		
			if (empty($row['type']) )
		{
			
		$montior_type = curl_get_montior_type($row['sn']);
		$montior_type = trim($montior_type);
		$s_pl_sql = "UPDATE montior ".
					"SET  type = '".
					$montior_type.
					"' ".
					"WHERE montior.sn = '".
					$row['sn'].
					"';"; 
		
		//$s_pl_sql = "INSERT INTO montior (sn,type) VALUES('".$pn_info."','".$montior_type."');";
	//echo $s_pl_sql ;
		$db->query($s_pl_sql);
		
		/*
		echo "<script language='javascript' type='text/javascript'>";
		echo "window.location.reload(); ";
		echo "</script>";
*/
		
		}
		
		
		
		
		
		
		echo "<td class='tabval'>".htmlspecialchars($row['type'])."&nbsp;</td>";
		echo "<td class='tabval'>".$montior_type."&nbsp;</td>";
		echo "<td class='tabval'>"
				."<a href='http://support1.lenovo.com.cn/lenovo/wsi/usercenter/computersearch/StandardMyComputerSearch.aspx?id="
				.htmlspecialchars($row['sn'])
				."'>"
				.htmlspecialchars($row['sn'])
				."</a>"
				."&nbsp;</td>";
		
		
		
		
		echo "<td class='tabval' style='color:#f00'>"
				."<a href='./pn_info.php?pn="
				.htmlspecialchars($row['pn'])
				."&hidden_sn="
				.htmlspecialchars($row['sn'])
				."'>"
				.htmlspecialchars($row['pn'])
				."</a>"
				."&nbsp;</td>";
				
		echo "<td class='tabval'>".htmlspecialchars($row['mo'])."&nbsp;</td>";
		echo "<td class='tabval'>".htmlspecialchars($row['lucky'])."&nbsp;</td>";
		echo "<td class='tabval'>".htmlspecialchars($row['gc'])."&nbsp;</td>";
		echo "<td class='tabval'>".htmlspecialchars($row['montior'])."&nbsp;</td>";

		echo "<td class='tabval'><a onclick=\"return confirm('".$TEXT['phonebook-sure']."');\" href='sqlite3_1.php?action=del&id=".$row['id']."'><span class='red'>["."del"."]</span></a></td>";
		echo "<td class='tabval'></td>";
		echo "</tr>";
		$i++;

	}

	echo "<tr valign='bottom'>";
        echo "<td bgcolor='#fb7922' colspan='11'><img src=img/blank.gif width='1' height='8'></td>";
        echo "</tr>";

		
		$db->close(); //关闭


?>
	</table>
	
	
	
	
	
	
	
	
	
	
	
	
	
	












